/*
 * FifteenPuzzleNodeIDA.cpp
 *
 *  Created on: 18/05/2011
 *      Author: frandres
 */

#include "FifteenPuzzleNodeIDA.h"

	FifteenPuzzleNodeIDA::~FifteenPuzzleNodeIDA()
	{
	}

	FifteenPuzzleNodeIDA::FifteenPuzzleNodeIDA()
	{
	}

	bool FifteenPuzzleNodeIDA::isGoal(){

		for(int i = 0; i < 16; i++)
		{
			if(invBoard[i] != i)
				return false;
		}

		return true;

	}

	void FifteenPuzzleNodeIDA::print()
	{

		int board[16];
		int i = 0;

		for(; i < 16; i++)
			board[invBoard[i]] = i;

		for(i = 0; i < 16; i++)
		{

			cout << "|" << board[i];

			if(i % 4 == 3)
				cout << endl;

		}

		cout << endl;

	}

	void FifteenPuzzleNodeIDA::printInv()
	{
		for(int i = 0; i < 16; i++)
			cout << i << " -> " << invBoard[i] << endl;
	}

	void FifteenPuzzleNodeIDA::print(bool *X)
	{

		int board[16];
		int i = 0;

		for(; i < 16; i++)
			board[invBoard[i]] = i;

		for(i = 0; i < 16; i++)
		{

			if(!X[i])
				cout << "|" << board[i];
			else
				cout << "|X ";

			if(i % 4 == 3)
				cout << endl;

		}

		cout << endl;

	}

